Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-http

Package Overview
Dependencies
Maintainers
4
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-http

High-speed HTTP logger for Node.js

  • 2.6.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is pino-http?

pino-http is an HTTP logger middleware for Node.js that integrates with the Pino logging library. It provides high-performance logging for HTTP requests and responses, making it suitable for production environments where speed and efficiency are critical.

What are pino-http's main functionalities?

Basic HTTP Logging

This code sets up a basic HTTP server with pino-http middleware to log incoming requests and outgoing responses.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino();
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Custom Log Levels

This code demonstrates how to set custom log levels for the pino-http logger.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino({ level: 'debug' });
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Custom Log Formatting

This code shows how to customize the log output format using Pino's prettyPrint options.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino({
  prettyPrint: {
    colorize: true,
    translateTime: 'SYS:standard',
    ignore: 'pid,hostname'
  }
});
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Other packages similar to pino-http

FAQs

Package last updated on 24 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc